package com.r.pan.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.Getter;

@Getter
public enum CodeStatus {
    USED(1, "已使用"),
    NOT_USED(0, "未使用");

    @EnumValue
    @JsonValue
    private final Integer value;
    private final String desc;

    CodeStatus(Integer value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public static CodeStatus of(Integer value) {
        for (CodeStatus codeStatus : CodeStatus.values()) {
            if (codeStatus.value.equals(value)) {
                return codeStatus;
            }
        }
        return null;
    }
}
